package com.person.jiaiplan.assembler;

import com.person.jiaiplan.pojo.dto.expenses.ExpensesAddPlanReqDTO;
import com.person.jiaiplan.pojo.dto.expenses.ExpensesCountListResDTO;
import com.person.jiaiplan.pojo.entity.ExpensesCountLogs;
import com.person.jiaiplan.pojo.entity.ExpensesPlan;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * 花销转换类
 */
@Mapper
public interface ExpensesAssembler {

    ExpensesAssembler INSTANCE = Mappers.getMapper(ExpensesAssembler.class);

    /**
     * 花销计划请求转换为花销计划实体
     *
     * @param reqDTO
     * @return
     */
    ExpensesPlan reqDTO2ExpensesPlan(ExpensesAddPlanReqDTO reqDTO);

    @Mapping(target = "finishTime", source = "realTime", dateFormat = "yyyy-MM-dd")
    @Mapping(target = "planStartTime",source = "planStartTime", dateFormat = "yyyy-MM-dd")
    @Mapping(target = "planEndTime",source = "planFinishTime", dateFormat = "yyyy-MM-dd")
    ExpensesCountLogs reqDTO2ExpensesCount(ExpensesCountListResDTO reqDTO);
}
